<?php

namespace App\Http\Middleware;

use Closure;
use Overtrue\Socialite\User as SocialiteUser;

class MockUser
{
    public function handle($request, Closure $next)
    {

        if (\App::environment() == "local") {
            $user = new SocialiteUser([
                'id'       => 'o-gyyji93lipvNExvAA8EkYSxof8',//openid
                'name'     => 'mock',
                'nickname' => 'mock user',
                'avatar'   => '',
                'email'    => null,
                'original' => collect([
                    'sex'=>1,
                    'city'=>'广州',
                    'province'=>'广东',
                ]),
                'provider' => 'WeChat',
            ]);
            session(['wechat.oauth_user.default' => $user]);
        }
        return $next($request);
    }
}